function ndata =generateData(data, n_miss)

nindices(1)=0;
j=1;
size=length(data)
while length(nindices)<n_miss
val =round(rand()*size +1)
    for i=1:length(nindices)
        if nindices(i)==val
        encontro = 1
        break;
        end
        encontro = 0
    end
    
    if encontro == 0    
        nindices(j)=val
        j=j+1
    end

end

size = length(data)
for i=1:size
    if isval(nindices,i)==1
        ndata(i)=NaN;
    else
        ndata(i)=data(i);
    end
end